package com.wn.ziroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wn.ziroom.entity.Owner;
import com.wn.ziroom.mapper.OwnerMapper;
import com.wn.ziroom.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Service
public class OwnerServiceImpl extends ServiceImpl<OwnerMapper, Owner> implements OwnerService {

    private OwnerMapper ownerMapper;
    @Autowired
    public void setOwnerMapper(OwnerMapper ownerMapper) {
        this.ownerMapper = ownerMapper;
    }

    @Override
    public void addOwner(String phone) {
        Owner owner = new Owner();
        owner.setOwnerName("尊敬的业主");
        owner.setPhone(phone);
        ownerMapper.insert(owner);
    }

    @Override
    public Owner selectByPhoneNumber(String phone) {
        QueryWrapper<Owner> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("phone",phone);
        return ownerMapper.selectOne(objectQueryWrapper);
    }
}
